package com.smartstate.iot.controller;

import com.smartstate.common.web.httpResult.ApiResultIgnore;
import com.smartstate.iot.dto.PageDTO;
import com.smartstate.iot.entity.vo.HandOutVo;
import com.smartstate.iot.entity.vo.PageDto;
import com.smartstate.iot.entity.vo.PageResultDto;
import com.smartstate.iot.service.DataDistributionService;
import com.smartstate.iot.entity.vo.DataVo;
import com.smartstate.iot.vo.ResultVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/distribution")
public class DataDistributionController {

    @Autowired
    private DataDistributionService dataDistributionService;

    @PostMapping("/page")
    @ApiResultIgnore
    @ApiOperation(value = "数据分发分页查询")
    public ResultVO<PageResultDto> list(@RequestBody PageDTO dto) {
        return dataDistributionService.list(dto);
    }

    @PostMapping("/handout")
    @ApiResultIgnore
    @ApiOperation(value = "分发数据")
    public ResultVO<String> echo(@RequestBody HandOutVo handOutVo) {
        return dataDistributionService.handOut(handOutVo);
    }

    @DeleteMapping
    @ApiResultIgnore
    @ApiOperation(value = "删除手动分发的数据")
    public ResultVO<String> deleHandOut( String dataId,String originalTarget){
        return dataDistributionService.dele(dataId,originalTarget);
    }
}
